﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Blockey.GameObjects3D
{
    public class Condition
    {
        public Condition()
        {
            ChangeTypeToNeutral();
        }

        #region Methods

        public void UpdateTimer()
        {
            if (IsNotComplete && IsNotNeutral)
            {
                _Timer++;
                if (_Timer >= _EndTime)
                    _Completed = true;
            }
        }

        public void ChangeTypeToNeutral()
        {
            ChangeType(ConditionName.Neutral, STARTTIME);
        }
        public void ChangeType(ConditionName oName, int oEndTimer)
        {
            _CurrName = oName;
            _Timer = STARTTIME;
            _EndTime = oEndTimer;
            _Completed = false;
        }
        public void ChangeTypeForClient(ConditionName oName)
        {
            _CurrName = oName;
        }

        #endregion

        #region Properties

        public ConditionName Name
        {
            get { return _CurrName; }
        }
        public bool IsComplete
        { get { return _Completed; } }
        public bool IsNotComplete
        {
            get { return !_Completed; }
        }
        public bool IsNeutral
        {
            get { return _CurrName == ConditionName.Neutral; }
        }
        public bool IsNotNeutral
        {
            get { return _CurrName != ConditionName.Neutral; }
        }
        public int Timer
        {
            get { return _Timer; }
        }

        #endregion

        #region Fields

        private bool _Completed;
        private int _Timer;
        private int _EndTime;
        private ConditionName _CurrName;

        #endregion

        #region Constants

        private const int STARTTIME = 0;
        public const int ENDTIME_HITTING = 50;
        public const int ENDTIME_FALLING = 70;
        public const int ENDTIME_MISS_HIT_FALLING = 30;
        public const int ENDTIME_DIVE = 10;

        #endregion

    }
}
